﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using The_Chronicles_of_Asku.Areas.Tomb_Floors._10_20._15_20.Resources;
using The_Chronicles_of_Asku.Characters;

namespace The_Chronicles_of_Asku.Areas.Tomb_Floors._10_20._15_20
{
    class FloorNineteen
    {
        Battle battle = new Battle();
        Skeleton skel = new Skeleton();
        Necromancer necro = new Necromancer();
        Undead zombie = new Undead();
        SetMobLevels setLevel = new SetMobLevels();
        Hero myHero = new Hero();
        Villager villager = new Villager();
        public bool complete = false;

        public void theFloor(Hero myHero, Mob mob)
        {
            setLevel.setMobLevelTwentySeven(skel, necro, zombie, villager);

            Console.WriteLine(FloorNineteenText.Entrance);
            UndeadFight(myHero, zombie);
            UndeadFight(myHero, zombie);
            UndeadFight(myHero, zombie);
            UndeadFight(myHero, zombie);
            UndeadFight(myHero, zombie);
            UndeadFight(myHero, zombie);

            if (myHero.isAlive == true)
            {
                string answer = "";

                do
                {
                    Console.WriteLine(FloorNineteenText.FirstThing);
                    answer = Console.ReadLine();

                    switch (answer)
                    {
                        case "1":
                            Console.WriteLine(FloorNineteenText.FirstThingLeft);
                            NecromancerFight(myHero, necro);
                            NecromancerFight(myHero, necro);
                            VillagerFight(myHero, villager);
                            NecromancerFight(myHero, necro);
                            NecromancerFight(myHero, necro);
                            break;

                        case "2":
                            Console.WriteLine(FloorNineteenText.FirstThingRight);
                            SkeletonFight(myHero, skel);
                            SkeletonFight(myHero, skel);
                            SkeletonFight(myHero, skel);
                            SkeletonFight(myHero, skel);
                            SkeletonFight(myHero, skel);
                            SkeletonFight(myHero, skel);
                            SkeletonFight(myHero, skel);
                            SkeletonFight(myHero, skel);
                            break;

                        default:
                            Console.WriteLine("Invalid choice!");
                            ClearScreen();
                            break;
                    }
                } while (answer != "1" && answer != "2" && myHero.isAlive == true);
            }

            if (myHero.isAlive == true)
            {
                Console.WriteLine(FloorNineteenText.SecondThing);
                SkeletonFight(myHero, skel);
                UndeadFight(myHero, zombie);
                SkeletonFight(myHero, skel);
                UndeadFight(myHero, zombie);
                SkeletonFight(myHero, skel);
                UndeadFight(myHero, zombie);
                SkeletonFight(myHero, skel);
            }

            setLevel.setMobLevelTwentyEight(skel, necro, zombie, villager);

            if (myHero.isAlive == true)
            {
                Console.WriteLine(FloorNineteenText.ThirdThing);
                UndeadFight(myHero, zombie);
                UndeadFight(myHero, zombie);
                UndeadFight(myHero, zombie);
                UndeadFight(myHero, zombie);
                UndeadFight(myHero, zombie);
                UndeadFight(myHero, zombie);
            }

            setLevel.setMobLevelTwentyNine(skel, necro, zombie, villager);

            if (myHero.isAlive == true)
            {
                string answer = "";

                do
                {
                    Console.WriteLine(FloorNineteenText.FourthThing);
                    answer = Console.ReadLine();

                    switch (answer)
                    {
                        case "1":
                            Console.WriteLine(FloorNineteenText.FourthThingLeft);
                            NecromancerFight(myHero, necro);
                            NecromancerFight(myHero, necro);
                            NecromancerFight(myHero, necro);
                            NecromancerFight(myHero, necro);
                            NecromancerFight(myHero, necro);
                            NecromancerFight(myHero, necro);
                            NecromancerFight(myHero, necro);
                            NecromancerFight(myHero, necro);
                            NecromancerFight(myHero, necro);
                            NecromancerFight(myHero, necro);
                            NecromancerFight(myHero, necro);
                            NecromancerFight(myHero, necro);
                            NecromancerFight(myHero, necro);
                            NecromancerFight(myHero, necro);
                            NecromancerFight(myHero, necro);
                            NecromancerFight(myHero, necro);
                            break;

                        case "2":
                            Console.WriteLine(FloorNineteenText.FourthThingRight);
                            ClearScreen();
                            break;

                        default:
                            Console.WriteLine("Invalid choice!");
                            ClearScreen();
                            break;
                    }
                } while (answer != "1" && myHero.isAlive == true);
            }

            setLevel.setMobLevelThirty(skel, necro, zombie, villager);

            if (myHero.isAlive == true)
            {
                Random rnd = new Random();
                int goldInChest = rnd.Next(100, 1001);
                myHero.gold += goldInChest;
                if (myHero.gold >= myHero.goldCap)
                {
                    myHero.gold = myHero.goldCap;
                }
                int tempGold = myHero.gold;
                Console.WriteLine(FloorNineteenText.FifthThing, goldInChest, tempGold);
                SkeletonFight(myHero, skel);
                SkeletonFight(myHero, skel);
                UndeadFight(myHero, zombie);
                SkeletonFight(myHero, skel);
                UndeadFight(myHero, zombie);
                UndeadFight(myHero, zombie);
                SkeletonFight(myHero, skel);
                UndeadFight(myHero, zombie);
                UndeadFight(myHero, zombie);
                SkeletonFight(myHero, skel);
            }

            if (myHero.isAlive == true)
            {
                string answer = "";

                do
                {
                    Console.WriteLine(FloorNineteenText.SixthThing);
                    answer = Console.ReadLine();

                    switch (answer)
                    {
                        case "1":
                            if (myHero.isAlive == true)
                            {
                                Console.WriteLine(FloorNineteenText.SixthThingOne);
                                VillagerFight(myHero, villager);
                                VillagerFight(myHero, villager);
                                VillagerFight(myHero, villager);
                                VillagerFight(myHero, villager);
                                VillagerFight(myHero, villager);
                                VillagerFight(myHero, villager);
                                VillagerFight(myHero, villager);
                                VillagerFight(myHero, villager);
                            }
                            break;

                        case "2":
                            Random rnd = new Random();
                            int goldInChest = rnd.Next(100, 701);
                            myHero.gold += goldInChest;
                            if (myHero.gold >= myHero.goldCap)
                            {
                                myHero.gold = myHero.goldCap;
                            }
                            int tempGold = myHero.gold;
                            Console.WriteLine(FloorNineteenText.SixthThingTwo, goldInChest, tempGold);
                            ClearScreen();
                            break;

                        case "3":
                            Console.WriteLine(FloorNineteenText.SixthThingThree);
                            SkeletonFight(myHero, skel);
                            SkeletonFight(myHero, skel);
                            SkeletonFight(myHero, skel);
                            SkeletonFight(myHero, skel);
                            SkeletonFight(myHero, skel);
                            SkeletonFight(myHero, skel);
                            SkeletonFight(myHero, skel);
                            SkeletonFight(myHero, skel);
                            SkeletonFight(myHero, skel);
                            SkeletonFight(myHero, skel);
                            SkeletonFight(myHero, skel);
                            SkeletonFight(myHero, skel);
                            SkeletonFight(myHero, skel);
                            SkeletonFight(myHero, skel);
                            SkeletonFight(myHero, skel);
                            break;

                        default:
                            Console.WriteLine("Invalid choice!");
                            ClearScreen();
                            break;
                    }
                } while (answer != "1" && answer != "3" && myHero.isAlive == true);
            }

            if (myHero.isAlive == true)
            {
                Console.WriteLine(FloorNineteenText.SeventhThing);
                UndeadFight(myHero, zombie);
                UndeadFight(myHero, zombie);
                UndeadFight(myHero, zombie);
                UndeadFight(myHero, zombie);
                UndeadFight(myHero, zombie);
                UndeadFight(myHero, zombie);
                UndeadFight(myHero, zombie);
            }

            if (myHero.isAlive == true)
            {
                string answer = "";

                do
                {
                    Console.WriteLine(FloorNineteenText.EighthThing);
                    answer = Console.ReadLine();

                    switch (answer)
                    {
                        case "1":
                            Console.WriteLine(FloorNineteenText.EighthThingLeft);
                            VillagerFight(myHero, villager);
                            VillagerFight(myHero, villager);
                            VillagerFight(myHero, villager);
                            VillagerFight(myHero, villager);
                            VillagerFight(myHero, villager);
                            VillagerFight(myHero, villager);
                            VillagerFight(myHero, villager);
                            VillagerFight(myHero, villager);
                            VillagerFight(myHero, villager);
                            VillagerFight(myHero, villager);
                            VillagerFight(myHero, villager);
                            VillagerFight(myHero, villager);
                            break;

                        case "2":
                            Console.WriteLine(FloorNineteenText.EighthThingRight);
                            NecromancerFight(myHero, necro);
                            NecromancerFight(myHero, necro);
                            NecromancerFight(myHero, necro);
                            NecromancerFight(myHero, necro);
                            NecromancerFight(myHero, necro);
                            break;

                        default:
                            Console.WriteLine("Invalid choice!");
                            ClearScreen();
                            break;
                    }
                } while (answer != "1" && answer != "2" && myHero.isAlive == true);
            }

            if (myHero.isAlive == true)
            {
                Console.WriteLine(FloorNineteenText.NinthThing);
                NecromancerFight(myHero, necro);
                SkeletonFight(myHero, skel);
                UndeadFight(myHero, zombie);
                NecromancerFight(myHero, necro);
                UndeadFight(myHero, zombie);
                VillagerFight(myHero, villager);
                VillagerFight(myHero, villager);
                NecromancerFight(myHero, necro);
                VillagerFight(myHero, villager);
                VillagerFight(myHero, villager);
                UndeadFight(myHero, zombie);
                NecromancerFight(myHero, necro);
                VillagerFight(myHero, villager);
                UndeadFight(myHero, zombie);
                NecromancerFight(myHero, necro);
                VillagerFight(myHero, villager);
                UndeadFight(myHero, zombie);
                NecromancerFight(myHero, necro);
                SkeletonFight(myHero, skel);
                NecromancerFight(myHero, necro);
            }

            if (myHero.isAlive == true)
            {
                Console.WriteLine(FloorNineteenText.End);
                ClearScreen();
                complete = true;
            }

            if (myHero.isAlive == false)
            {
                Console.WriteLine(FloorNineteenText.Dead);
                myHero.isAlive = true;
            }
        }

        private void UndeadFight(Hero myHero, Undead zombie)
        {
            if (myHero.isAlive == true)
            {
                battle.Fight(myHero, zombie);
                Console.ReadKey();
            }
            myHero.ResetStats(myHero);
            zombie.ResetStats(zombie);

            Console.Clear();
        }

        private void SkeletonFight(Hero myHero, Skeleton skel)
        {
            if (myHero.isAlive == true)
            {
                battle.Fight(myHero, skel);
                Console.ReadKey();
            }
            myHero.ResetStats(myHero);
            skel.ResetStats(skel);

            Console.Clear();
        }

        private void NecromancerFight(Hero myHero, Necromancer necro)
        {
            if (myHero.isAlive == true)
            {
                battle.Fight(myHero, necro);
                Console.ReadKey();
            }
            myHero.ResetStats(myHero);
            necro.ResetStats(necro);

            Console.Clear();
        }

        private void VillagerFight(Hero myHero, Villager villager)
        {
            if (myHero.isAlive == true)
            {
                battle.Fight(myHero, villager);
                Console.ReadKey();
            }
            myHero.ResetStats(myHero);
            villager.ResetStats(villager);

            Console.Clear();
        }

        private void ClearScreen()
        {
            Console.ReadKey();
            Console.Clear();
        }
    }
}
